package cn.itcast.service.log.impl;

import cn.itcast.dao.log.SysLogDao;
import cn.itcast.domain.log.SysLog;
import cn.itcast.service.log.LogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service
@Transactional
public class LogServiceImpl implements LogService {
    @Autowired
    SysLogDao sysLogDao;

    @Override
    public PageInfo<SysLog> findByPage(String companyId, int pageNum, int pageSize) {
        //分页
        PageHelper.startPage(pageNum,pageSize);
        List<SysLog> list = sysLogDao.findAll(companyId);
        PageInfo<SysLog> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void save(SysLog log) {
        log.setId(UUID.randomUUID().toString());
        sysLogDao.save(log);
    }
}
